package com.xavier.vo;

import cn.hutool.core.util.ObjectUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@Schema(description = "菜单出参")
public class MenuDetailVO implements Serializable {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 1L;


    /**
     * id
     */
    @Schema(description = "id")
    private Long id;

    /**
     * 父id
     */
    @Schema(description = "父id")
    private Long parentId;

    /**
     * 菜单类型
     */
    @Schema(description = "菜单类型")
    private Byte menuType;

    /**
     * 菜单编码
     */
    @Schema(description = "菜单编码")
    private String menuCode;

    /**
     * 菜单名称
     */
    @Schema(description = "菜单名称")
    private String menuName;

    /**
     * 组件路径
     */
    @Schema(description = "组件路径")
    private String component;

    /**
     * 组件名称
     */
    @Schema(description = "组件名称")
    private String componentName;

    /**
     * 地址
     */
    @Schema(description = "地址")
    private String url;

    /**
     * 图标
     */
    @Schema(description = "图标")
    private String icon;

    /**
     * 是否外链
     */
    @Schema(description = "是否外链")
    private Boolean isExt;

    /**
     * 是否缓存
     */
    @Schema(description = "是否缓存")
    private Boolean isCache;

    /**
     * 是否展示
     */
    @Schema(description = "是否展示")
    private Boolean isShow;

    /**
     * 是否启用
     */
    @Schema(description = "是否启用")
    private Boolean isEnable;

    /**
     * 排序
     */
    @Schema(description = "排序")
    private Integer sortNumber;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    /**
     * 子菜单列表
     */
    @Schema(description = "子菜单列表")
    private List<MenuDetailVO> childList;

    /**
     * 增加子菜单
     */
    public void addChildList(MenuDetailVO vo) {
        if (ObjectUtil.isEmpty(childList)) {
            childList = new ArrayList<>();
        }
        childList.add(vo);
    }


}
